package pl.nazaweb.imedproplus.model.facade;

import java.util.List;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import pl.nazaweb.imedproplus.model.entity.Staff;

@Stateless
@LocalBean
public class StaffFacade extends AbstractFacade<Staff> {

    @PersistenceContext(unitName = AbstractFacade.peristanceUnitName)
    private EntityManager entityManager;

    public StaffFacade() {
        super(Staff.class);
    }

    @Override
    protected EntityManager getEntityManager() {
        return this.entityManager;
    }

    @Override
    public void remove(Staff entity) {
        this.getEntityManager()
                .createNativeQuery("delete from staff where id="+entity.getId())
                .executeUpdate();
    }

    @Override
    public void remove(List<Staff> entityList) {
        for(Staff staff : entityList){
            this.remove(staff);
        }
    }

}
